home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0793 / COMPBAR.PAS < prev    next >
Pascal/Delphi Source File  |  1993-08-01  |  2KB  |  58 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 383 of 447                                                               
  3. From : Raphael Vanney                      2:320/7.0            22 Jul 93  20:56 
  4. To   : Paul Staton                                                               
  5. Subj : Source code                                                            
  6. ────────────────────────────────────────────────────────────────────────────────
  7. Hi !
  8.  
  9. PS>Does anyone have some source to make a scrolling completion bar such as
  10. PS> the ones found in most install programs for store bought programs.
  11. PS> I will be read the total conferance areas and then make the bar.
  12. PS> The total, whatever it is needs to fit into a fixed number of spaces,
  13. PS> ie, 80 conferences, bar length say 30.
  14.  
  15. PS> 0%         50%         100%
  16.  
  17. ------------------------------------------------------------ Cut here}
  18. Uses Crt ;
  19.  
  20. Procedure DrawBar(  x, y      : Integer ;
  21.                     Current,
  22.                     Total     : LongInt ;
  23.                     Width     : Integer) ;
  24. { x, y         : Coordinates where to display the bar       }
  25. { Current      : Current number of operations completed     }
  26. { Total        : Total # to complete                        }
  27. { Width        : Maximum width of the bar                   }
  28. Var  Len  : Integer ;
  29.      i    : Integer ;
  30. Begin
  31.      Len:=Current*Width Div Total ;
  32.  
  33.      { Set up first line }
  34.      GoToXY(x, y) ; Write('0%') ;
  35.      GoToXY(x+Width Div 2-1, y) ; Write('50%') ;
  36.      GoToXY(x+Width-4, y) ; Write('100%') ;
  37.  
  38.      { Draw bar }
  39.      GoToXY(x, y+1) ;
  40.      For i:=1 To Len Do Write(#176) ;
  41. End ;
  42.  
  43. Var  i    : Integer ;
  44.  
  45. Begin
  46.      ClrScr ;
  47.      For i:=1 To 80 Do
  48.      Begin
  49.           DrawBar(5, 5, i, 80, 30) ;
  50.           Delay(100) ;
  51.      End ;
  52. End.
  53. ------------------------------------------------------------ Cut here
  54.  
  55. Of course, it lacks some enhancements : for instance, you could use
  56. characters #219, #221 and #222. The procedure should not redraw the
  57. percentage line each time, nor should it redraw the bat if the length
  58. has not changed between two calls...